package controller;

import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import javax.swing.JButton;

import view.ListView;

/**
 * 
 * @author Nelly-Kim TRAN
 * 
 * To fire up the default web browser when we click on someone's homepage
 * 
 * @param bouton
 * 				to get the text written on the button (the website address)
 *
 */


public class HomepageListener implements ActionListener{
	
	JButton bouton;;
	
	public HomepageListener(JButton bouton) {
		this.bouton=bouton;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		
		String htmlFile = bouton.getText();
		try {
			Desktop.getDesktop().browse(new URI(htmlFile));
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (URISyntaxException e2) {
			// TODO Auto-generated catch block
			e2.printStackTrace();
		}
		
	}

}
